package com.masterclient.app.modules.goods.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.masterclient.app.R;
import com.eoner.baselibrary.bean.goods.GoodDetailBean;

import java.util.List;

/**
 * 作者：sean
 * 创建时间：2017/6/30 16:05
 * 功能说明：
 */

public class ManBaoYouAdapter extends BaseAdapter{
    private List<GoodDetailBean.DataBean.ShippingPromotionBean> list;
    private Context context;
    public ManBaoYouAdapter(Context context, List<GoodDetailBean.DataBean.ShippingPromotionBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list == null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        GoodDetailBean.DataBean.ShippingPromotionBean bean = list.get(position);
        View view = View.inflate(context, R.layout.item_baoyou,null);
        TextView tv = (TextView) view.findViewById(R.id.tv_title);
       tv.setText(Html.fromHtml("<img src='" + R.mipmap.img2_youhui_shop + "'>  "+bean.getSh_description(),new Html.ImageGetter() {
            @Override
            public Drawable getDrawable(String source) {
                int id = Integer.parseInt(source);
                Drawable drawable = context.getResources().getDrawable(id);
                drawable.setBounds(0, 0, drawable.getIntrinsicWidth() ,
                        drawable.getIntrinsicHeight());
                return drawable;
            }
        },null));
        return view;
    }
}
